package org.shagin.jfin.ui.editor.budget;

import java.awt.Container;

import org.shagin.jfin.core.CoreUtils;
import org.shagin.jfin.core.ui.UIUtils;
import org.shagin.jfin.data.model.IBudget;

/**
 * The Class BudgetEditor.
 */
public class BudgetEditor {

    private IBudget budget;

    /**
     * Instantiates a new budget editor.
     * 
     * @param budget the budget
     */
    public BudgetEditor(IBudget budget) {
        CoreUtils.checkNotNull(budget, "budget");
        this.budget = budget;
    }

    /**
     * Edits the.
     * 
     * @param container the container
     */
    public void edit(Container container) {
        CoreUtils.assertNotNull(budget, "budget");
        BudgetEditorFrame frame = new BudgetEditorFrame(budget);
        frame.setTitle(budget.getId());
        UIUtils.resizeAndCenterContainer(container, frame, 0.8d, 0.9d);
        frame.setVisible(true);
    }

    /**
     * Edits the.
     */
    public void edit() {
        edit(null);
    }
}
